Fix watcher last modified comparison#328
Fix watcher last modified comparison#328walterhiggins merged 1 commit intowalterhiggins:developmentfrom
Conversation
|
Actually I think you've found a different kind of bug there. You're right that there is an object that's being returned. But the object isn't a Java.util.Date object. I believe that's the function definition for The rule is that if you reference So what do you think about the fix being to ensure that lastModified is always used as a function() rather than as a property? Then the value of lm will be a Long as expected, which might someday be important to other code that someone might add in there. If you agree, then please withdraw the PR, and I'll get this fix into my version of the code and will close this when it gets merged into a release. |
|
@TonyGravagno thanks for taking a look at this. I'm not familiar with the Nashorn side of things and how it bridges Java to JavaScript, but the values in that area of the code from the JavaScript context are objects of type // modification at line 167
var lm = dirObject.lastModified();
var dw = dirsWatched[dir];
var dwLm = dirsWatched[dir].lastModified;
console.log(lm.getClass().getName()); // outputs: java.lang.Long
console.log(dwLm.getClass().getName()); // outputs: java.lang.LongIt seems like java.lang.Long isn't correctly translating to a JavaScript
I totally agree it would be better to not have to manually cast it to a string or number - I'll defer to your fix and close this. Hope this helps. Thanks again for your efforts and sharing ScriptCraft. |
|
Re-opening just to make sure this gets handled. |
|
For the pathologically curious, this bug is the result of a subtle change in Nashorn behaviour introduced in a Java 8 update (see this thread for the gory details: http://mail.openjdk.java.net/pipermail/nashorn-dev/2016-August/006424.html). Nashorn used to map Java |
|
Change also added into v3.2.3.4. |
The file/directory watcher is firing the changed callback when the file or directory has not changed. This affects classroom mode causing all player plugins to be reloaded every 3 seconds.
The current lastModified check is comparing objects (which will always result in
!=not equals). This fix casts the lastModified objects to string to compare the timestamps as strings.